package com.tour.service.impl;

import com.tour.config.ResponseWrapper;
import com.tour.entity.Discuss;
import com.tour.mapper.DiscussMapper;
import com.tour.service.DiscussService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lel
 * @since 2020-12-30
 */
@Service
public class DiscussServiceImpl extends ServiceImpl<DiscussMapper, Discuss> implements DiscussService {

    @Autowired
    DiscussMapper discussMapper;

    public ResponseWrapper addDiscuss(Discuss discuss){
        if (discuss != null){
            int result = discussMapper.insert(discuss);
            if (result == 1){
                return ResponseWrapper.markCustom(true,200,"发布成功",null);
            }else {
                return ResponseWrapper.markError();
            }
        }else {
            return ResponseWrapper.markError();
        }
    }    public ResponseWrapper delDiscuss(Integer discussId){
        if (discussId != null){
            int result = discussMapper.deleteById(discussId);
            if (result == 1){
                return ResponseWrapper.markCustom(true,200,"删除成功",null);
            }else {
                return ResponseWrapper.markError();
            }
        }else {
            return ResponseWrapper.markError();
        }
    }

}
